<?php



class tx_zlib_viewhelper_popup extends tx_zlib_abstract_viewhelper
{

	/**
	 * Generates a popup link adding a js onclick (acts as a wrapper)
	 *
	 * @param string $str
	 * @param string $winName
	 * @param array $winParams
	 * @return string The wrapped html link with the popup js
	 */
	public function popup($str, $winName='', array $winParams=array())
	{
		// default values
		$winParams['width'] = isset($winParams['width']) ? $winParams['width'] : 670;
		$winParams['height'] = isset($winParams['height']) ? $winParams['height'] : 500;
		$winParams['status'] = isset($winParams['status']) ? $winParams['status'] : 0;
		$winParams['menubar'] = isset($winParams['menubar']) ? $winParams['menubar'] : 0;
		$winParams['scrollbars'] = isset($winParams['scrollbars']) ? $winParams['scrollbars'] : 0;
		$winParams['resizable'] = isset($winParams['resizable']) ? $winParams['resizable'] : 0;

		$winParamsStr = '';
		$delim = '';
		foreach($winParams AS $key=>$val) {
			$winParamsStr .= sprintf('%s%s=%s', $delim, $key, $val);
			$delim = ',';
		}
		return $this->getPi()->pi_openAtagHrefInJSwindow($str, $winName, $winParamsStr);
	}

}


if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/zlib/views/helpers/class.tx_zlib_viewhelper_popup.php'])	{
	include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/zlib/views/helpers/class.tx_zlib_viewhelper_popup.php']);
}
